package com.yutianran.springBoot;

import com.yutianran.springBoot.util.FileUtil;

import java.io.File;

public class DotMain {

    public static void main(String[] args) throws Exception {
        DotMain dotMain = new DotMain();
        String path = "C:\\Users\\DELL\\code\\springBoot\\src\\main\\resources\\dot\\dot.dot";
        File file = new File(path);
        String dotFormat = FileUtil.readBytesToString(file);
        dotMain.createDotGraph(dotFormat, "DotGraph");
    }

    public void createDotGraph(String dotFormat, String fileName) {
        GraphViz gv = new GraphViz();
        gv.addln(gv.start_graph());
        gv.add(dotFormat);
        gv.addln(gv.end_graph());
        // String type = "gif";
        String type = "png";
        // gv.increaseDpi();
        gv.decreaseDpi();
        gv.decreaseDpi();
        File out = new File("C:\\Users\\DELL\\code\\springBoot\\src\\main\\resources\\dot", fileName + "." + type);
        FileUtil.requireFileNotNull(out);
        gv.writeGraphToFile(gv.getGraph(gv.getDotSource(), type), out);
    }
}
